/*    */ package com.zimbra.qa.unittest;
/*    */ 
/*    */ import com.zimbra.client.ZMailbox;
/*    */ import com.zimbra.client.ZMessage;
/*    */ import com.zimbra.client.ZMessage.ZMimePart;
/*    */ import com.zimbra.common.localconfig.KnownKey;
/*    */ import com.zimbra.common.localconfig.LC;
/*    */ import com.zimbra.common.util.ByteUtil;
/*    */ import java.io.File;
/*    */ import junit.framework.TestCase;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class TestConversion
/*    */   extends TestCase
/*    */ {
/*    */   private static final String USER_NAME = "user1";
/* 33 */   private static final String NAME_PREFIX = TestConversion.class.getSimpleName();
/*    */   
/*    */   public void setUp()
/*    */     throws Exception
/*    */   {
/* 38 */     cleanUp();
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */   public void testTnef()
/*    */     throws Exception
/*    */   {
/* 46 */     ZMailbox mbox = TestUtil.getZMailbox("user1");
/*    */     
/*    */ 
/* 49 */     String msgContent = new String(ByteUtil.getContent(new File(LC.zimbra_home.value() + "/unittest/tnef.msg")));
/*    */     
/* 51 */     TestUtil.addMessageLmtp(new String[] { "user1" }, "user1", msgContent);
/*    */     
/*    */ 
/* 54 */     ZMessage msg = TestUtil.getMessage(mbox, "in:inbox subject:\"" + NAME_PREFIX + " Rich text (TNEF) test\"");
/* 55 */     byte[] data = TestUtil.getContent(mbox, msg.getId(), "upload.gif");
/* 56 */     assertEquals(73, data.length);
/* 57 */     data = TestUtil.getContent(mbox, msg.getId(), "upload2.gif");
/* 58 */     assertEquals(851, data.length);
/*    */     
/* 60 */     ZMessage.ZMimePart part = TestUtil.getPart(msg, "upload.gif");
/* 61 */     checkPartSize(73L, part.getSize());
/* 62 */     part = TestUtil.getPart(msg, "upload2.gif");
/* 63 */     checkPartSize(851L, part.getSize());
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */   private void checkPartSize(long expected, long actual)
/*    */   {
/* 70 */     assertTrue("expected " + expected + " +/- 4 bytes, got " + actual, Math.abs(expected - actual) <= 4L);
/*    */   }
/*    */   
/*    */   public void tearDown()
/*    */     throws Exception
/*    */   {
/* 76 */     cleanUp();
/*    */   }
/*    */   
/*    */   private void cleanUp() throws Exception
/*    */   {
/* 81 */     TestUtil.deleteTestData("user1", NAME_PREFIX);
/*    */   }
/*    */   
/*    */   public static void main(String[] args) throws Exception
/*    */   {
/* 86 */     TestUtil.cliSetup();
/* 87 */     TestUtil.runTest(TestConversion.class);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestConversion.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */